package com.xinhe.web.reposity;

import com.xinhe.web.entity.SeckillTime;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SeckillTimeRepository  extends JpaRepository<SeckillTime, Long> {
    @Query(value = "select * from tb_seckill_time where removed = 0 and DATE_FORMAT(now(), '%H:%i:%S') between DATE_FORMAT(start_time, '%H:%i:%S') and DATE_FORMAT(end_time, '%H:%i:%S')", nativeQuery = true)
    List<SeckillTime> findCurrentSeckillTime();
    @Query(value = "select * from tb_seckill_time where removed = 0 and DATE_FORMAT(start_time, '%H:%i:%S') >= DATE_FORMAT(now(), '%H:%i:%S') order by start_time", nativeQuery = true)
    List<SeckillTime> findLatelySeckillTime();
}
